﻿using System.Collections.Generic;
using System.Linq;

namespace Mbl.ParameterizedTest
{
    internal static class CollectionFormatter
    {
        public static string Format<T>(IEnumerable<T> collection)
        {
            if (collection == null)
            {
                return ValueFormat.Null;
            }

            return "[" + string.Join(", ", collection.Select(FormatElement)) + "]";
        }

        private static string FormatElement<T>(T element)
        {
            return element == null 
                ? ValueFormat.Null 
                : element.ToString();
        }
    }
}
